Add revision-guarded PTY send - #133
Draft
myobie wants to merge 3 commits into
Draft
Conversation
# Conflicts: # docs/client.md # src/protocol.ts # src/server.ts # tests/protocol.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
generationand monotonicioRevisionthrough STATUS,queryStats(), andpty statscompareAndSend()API andGUARDED_DATAprotocol packetWhy
An adapter can hold fresh idle authority and check its own composer fixtures, but input, output, resize, activity, or restart can race before delivery. A daemon-owned exact revision token closes that race without interpreting terminal bytes.
Closes #132. Depends on draft PR #131 / issue #129. This stacked draft targets
agent/pty-activity-statusso its diff contains only guarded-send work.Race proof
The socket packet loop processes ordinary DATA, resize, activity, and guarded packets synchronously in order. All delivery-relevant mutation paths advance one per-generation counter. A guarded request compares both tokens immediately before
pty.write()in that same event-loop turn; successful write advances the revision, making replay impossible. Rejection performs no PTY write and does not alter the activity lease.The combined fixture contract keeps the layers separate: only explicit
idleis adapter-eligible, while exact generation/revision independently gates the mechanical write. Alternate-screen/Vim-like state is diagnostic and never grants authority.Validation
npm run typechecknpm run buildnpm run verify-docs— 13 passedIncomplete terminfo entryDraft only. No merge or deployment.